# coding=utf-8
# 代码文件：chapter3/ch3.2.4.py

import xlwings as xw

app = xw.App(visible=False, add_book=False)
f = r'data/学生信息.xlsx'
wb = app.books.open(f)

sheet1 = wb.sheets['Sheet1']

print('--------方法 1选择区域-------')
rng1 = sheet1.range('A1').current_region
rows = rng1.rows.count                              # 获取区域行数
print('行数', rows)

columns = rng1.columns.count                        # 获取区域列数
print('列数', columns)

print('--------方法 2选择区域-------')
rng2 = sheet1.range("a1").expand()
# rng = sheet1.range('A1').options(expand='table')

rows = rng2.rows.count                              # 获取区域行数
print('行数', rows)

columns = rng2.columns.count                        # 获取区域列数
print('列数', columns)

wb.close()
app.quit()

print('Game Over')